<?php

 
namespace RedMVC\Mail;

/**
 * Attachment class
 *  
 * @category    RedMVC
 * @package     Mail
 * @author      Jan Fischer, bitWorking <info@bitworking.de>
 */
class Attachment{
    public $name;
    public $size;
    public $data;
    public $type;

    public function __construct($file = null){
        if(null !== $file && file_exists($file)){
            $this->name = basename($file);
            $this->size = filesize($file);
            $this->data = chunk_split(base64_encode(file_get_contents($file)));
            if(function_exists('mime_content_type')){
                $this->type = mime_content_type($file);
            }
            else{
                $this->type = 'application/octet-stream';
            }
        }
    }
}